home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000008_icon-group-sender _Sat Jan 4 14:27:03 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Mon, 6 Jan 1997 06:20:04 MST
To: icon-group@cs.arizona.edu
Date: 4 Jan 1997 14:27:03 GMT
From: espie@aviso.ens.fr (Marc Espie)
Message-Id: <5alpbn$3kd@nef.ens.fr>
Organization: Ecole Normale Superieure, Paris
Sender: icon-group-request@cs.arizona.edu
References: <32CDB3E4.3358@ohsu.edu>
Subject: Re: Another Question from the Neophyte
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1869
In article <32CDB3E4.3358@ohsu.edu>,
Stuart Robinson <robinstu@ohsu.edu> wrote:
>But I've run into a new problem. I have found numerous options for
>scanning forward in a string, but I haven't found a good way to move
>backwards, besides first reversing a string and then scanning forward
>(which is functionally scanning backwards).
>For example, I created the following little program to extract the names
>of some functions nestled at the end of some lines of HTML (see input
>below):
>
>=======================
>procedure main()
>
>while line := reverse(read()) do
>line ?
>
>{
>write(reverse(tab(upto(" "))))
^^^
bad code... upto() takes a cset as an argument. You're suffering an hidden
conversion string->cset here. Use tab(upto(' ')) instead.
>cset()
>string()
>find()
>etc.
>
>I did manage to find a solution, but isn't there less cumbersome way of
>scanning backwards than using reverse()?
>
You can write reverse functions to upto and friends. This is rather easy
using &subject and &pos. The most difficult part is to get the generator
part okay. I remember seeing some of Icon's matching functions written in
Icon in the Icon book.
Some function along these lines should work (untested code...caution):
procedure downto(c, s, i1, i2)
/i1 = if /s then &pos else *s
/s = &subject
/i2 = 1
every i := i1 to i2 by -1 do
if member(c, s[i]) then suspend i
end
This might give some performance hit, though. In case this is not
acceptable, locating the rtl code for upto and writing a reverse function
should be a breeze... even though this is most certainly not suitable for
the Icon main distribution.
--
[nosave]<http://www.eleves.ens.fr:8080/home/espie/index.html>
microsoft network is EXPLICITLY forbidden to redistribute this message.
`Seiza no matataki kazoe, uranau koi no yuku e.'
Marc Espie (Marc.Espie@ens.fr)